﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace boardv2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
            


            
            
        }
        //Sets column Drop button numbers
        int c1 = 7;
        int c2 = 7;
        int c3 = 7;
        int c4 = 7;
        int c5 = 7;
        int c6 = 7;
        int c7 = 7;
        //sets player turn
        int player = 1;
        //Code for each column
        public void Drop_Click(object sender, EventArgs e)
        {
            //sets the array for the column
            Button[] buttonArray = new Button[8] { button1, button2, button3, button4, button5, button6, button7, button8 };
            //Checks if row is filled and finds lowest open space           
            if (c1 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray[c1].BackColor = Color.Red;
                    
                }
                else
                    buttonArray[c1].BackColor = Color.Blue;
                    
               
            }


            //next player turn, next space above
            player++;
            c1--;
            //disable button after column is filled
            if (c1 == -1)
            {
                Drop.Enabled = false;
            }
        }

        public void Drop2_Click(object sender, EventArgs e)
        {
            Button[] buttonArray2 = new Button[8] { button9, button10, button11, button12, button13, button14, button15, button16 };

            if (c2 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray2[c2].BackColor = Color.Red;

                }
                else
                    buttonArray2[c2].BackColor = Color.Blue;


            }



            player++;
            c2--;
            if (c2 == -1)
            {
                Drop2.Enabled = false;
            }

        }

        public void Drop3_Click(object sender, EventArgs e)
        {
            Button[] buttonArray3 = new Button[8] { button17, button18, button19, button20, button21, button22, button23, button24 };

            if (c3 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray3[c3].BackColor = Color.Red;

                }
                else
                    buttonArray3[c3].BackColor = Color.Blue;


            }



            player++;
            c3--;
            if (c3 == -1)
            {
                Drop3.Enabled = false;
            }

        }

        public void Drop4_Click(object sender, EventArgs e)
        {
            Button[] buttonArray4 = new Button[8] { button25, button26, button27, button28, button29, button30, button31, button32 };

            if (c4 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray4[c4].BackColor = Color.Red;

                }
                else
                    buttonArray4[c4].BackColor = Color.Blue;


            }



            player++;
            c4--;
            if (c4 == -1)
            {
                Drop4.Enabled = false;
            }

        }

        public void Drop5_Click(object sender, EventArgs e)
        {
            Button[] buttonArray5 = new Button[8] { button33, button34, button35, button36, button37, button38, button39, button40 };

            if (c5 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray5[c5].BackColor = Color.Red;

                }
                else
                    buttonArray5[c5].BackColor = Color.Blue;


            }



            player++;
            c5--;
            if (c5 == -1)
            {
                Drop5.Enabled = false;
            }

        }

        public void Drop6_Click(object sender, EventArgs e)
        {
            Button[] buttonArray6 = new Button[8] { button41, button42, button43, button44, button45, button46, button47, button48 };

            if (c6 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray6[c6].BackColor = Color.Red;

                }
                else
                    buttonArray6[c6].BackColor = Color.Blue;


            }



            player++;
            c6--;
            if (c6 == -1)
            {
                Drop6.Enabled = false;
            }
        }

        public void Drop7_Click(object sender, EventArgs e)
        {
            Button[] buttonArray7 = new Button[8] { button49, button50, button51, button52, button53, button54, button55, button56 };

            if (c7 >= 0)
            {
                if ((player % 2) == 0)
                {
                    buttonArray7[c7].BackColor = Color.Red;

                }
                else
                    buttonArray7[c7].BackColor = Color.Blue;


            }



            player++;
            c7--;
            if (c7 == -1)
            {
                Drop7.Enabled = false;
            }

        }



        Button[ , ] Board = new Button[7, 8];

        

         
        
        
    }
}
